package org.taobao.ibatiside.ui.binding;

import java.util.Collections;
import java.util.List;

import org.eclipse.core.databinding.conversion.IConverter;
import org.eclipse.core.resources.IFile;
import org.taobao.ibatiside.core.IbatisConstant;
import org.taobao.ibatiside.core.filemodel.FileProber;

public class ExtractConfigConverter implements IConverter {

	@Override
	public Object getFromType() {
		return IFile.class;
	}

	@Override
	public Object getToType() {
		return String.class;
	}

	@Override
	public Object convert(Object fromObject) {
		IFile file = (IFile) fromObject;
		if (file == null || !file.isAccessible()) return Collections.EMPTY_LIST;
		else return FileProber.getMapResources(file, IbatisConstant.VERSION_TWO);
	}

}
